package com.my.wemedia.controller.v1;

import com.my.model.admin.dtos.SensitiveReqDto;
import com.my.model.common.dtos.ResponseResult;
import com.my.model.wemedia.pojos.WmSensitive;
import com.my.wemedia.mapper.WmSensitiveMapper;
import com.my.wemedia.service.WmSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Transactional
@RequestMapping("/api/v1/sensitive")
public class WmNewsSensitiveController {
    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 获取敏感词列表
     * @return
     */
    @PostMapping("/list")
    public ResponseResult sensitiveList(@RequestBody SensitiveReqDto dto) {
        return wmSensitiveService.getSensitiveList(dto);
    }

    /**
     * 新增敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.saveSensitive(wmSensitive);
    }

    /**
     * 修改敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.updateSensitive(wmSensitive);
    }

    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitive(@PathVariable Integer id) {
        return wmSensitiveService.deleteSensitive(id);
    }
}
